#pragma once

#ifndef __BIT_HELPER_H__
#define __BIT_HELPER_H__

#include "Common.h"
#include "LogManager.h"

const int BYTE_SIZE = sizeof(byte);

// Helper for bit operations.
class BitHelper
{
public:
	// Add a value to a byte array.
	template<typename T>
	static void Add(vector<char>& buffer, const T& value);

	// Add a string to a byte array.
	static void Add(vector<char>& buffer, const string& value);

	// Convert a byte array into a value of a generic type.
	template<typename T>
	static T Convert(vector<char>& buffer);

	// Convert a byte array into a string value.
	static string Convert(vector<char>& buffer);

	// Encrypt a text with a given key.
	static string Encrypt(const string& text, const unsigned int& key);

private:
	// Add a 7 bit encoded integer to a buffer.
	static void Add7BitEncodedInt(vector<char>& buffer, const int& value);
};

#endif  // __BIT_HELPER_H__